import getcatgory from "../../api/mvRequest/getcatgory";
export default {
  namespaced: true,
  state: () => ({
    // 轮番图图片
    mvImage: [],
  }),
  mutations: {
    GETLIST(state, banners) {
      // 没有长度分两种：1.初始化  2.刷新
      state.mvImage = banners;
      //本地
      localStorage.setItem("catgoryImg", JSON.stringify(banners));
    },
  },
  actions: {
    // 请求
    async getList({ commit }) {
      const re = await getcatgory("/banner");
      commit("GETLIST", re.banners);
    },
  },
  getters: {
    getMvImage(state) {
      state.mvImage = JSON.parse(localStorage.getItem("catgoryImg"));
      return state.mvImage;
    },
  },
};
